function loadXMLDocInfo(url, game, info)
{
	var req;
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processInfo(req, game, info, false);
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processInfo(req, game, info, false);
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processInfo(req, game, info, process) 
{
	if (!process) 
		return function() { processInfo(req, game, info, true); };

	var div = get_game_info(game);

	if (req.readyState == 1)
	{
		div.innerHTML = "Wait...";
//		game.onclick = null;
	}

	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			// ...processing statements go here...
			/*
			response  = req.responseXML.documentElement;
			method    =
				response.getElementsByTagName('method')[0].firstChild.data;
			result    = 
				response.getElementsByTagName('result')[0].firstChild.data;
			eval(method + '(\'\', result)');
			*/
			if (div) div.innerHTML = req.responseText;
			info.onclick = function() { displayInfo(game); };
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function writeInfo(id, game, info)
{
	loadXMLDocInfo('game_info.php?game=' + id, game, info);
	displayInfo(game);
}

function get_game_info(game)
{
	var nodes = game.getElementsByTagName("*");
	for (i = 0; i < nodes.length; ++i)
	{
		if (nodes[i].className == 'game_info')
		{
			return nodes[i];
		}
	}
	return null;
}

function displayInfo(game)
{
	var div = get_game_info(game);
	div.style.display = 'block';
}

function hideInfo(game)
{
	var div = get_game_info(game);
	div.style.display = 'none';
}
